package com.ruoyi.project.orderSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.orderSystem.domain.TaskStation;
import com.ruoyi.project.orderSystem.service.ITaskStationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 任务站点Controller
 * 
 * @author wangshuo
 * @date 2021-01-26
 */
@RestController
@RequestMapping("/orderSystem/taskStation")
public class TaskStationController extends BaseController
{
    @Autowired
    private ITaskStationService taskStationService;

    /**
     * 查询任务站点列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskStation taskStation)
    {
        startPage();
        List<TaskStation> list = taskStationService.selectTaskStationList(taskStation);
        return getDataTable(list);
    }

    /**
     * 导出任务站点列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:export')")
    @Log(title = "任务站点", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TaskStation taskStation)
    {
        List<TaskStation> list = taskStationService.selectTaskStationList(taskStation);
        ExcelUtil<TaskStation> util = new ExcelUtil<TaskStation>(TaskStation.class);
        return util.exportExcel(list, "taskStation");
    }

    /**
     * 获取任务站点详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(taskStationService.selectTaskStationById(id));
    }

    /**
     * 新增任务站点
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:add')")
    @Log(title = "任务站点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskStation taskStation)
    {
        return toAjax(taskStationService.insertTaskStation(taskStation));
    }

    /**
     * 修改任务站点
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:edit')")
    @Log(title = "任务站点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskStation taskStation)
    {
        return toAjax(taskStationService.updateTaskStation(taskStation));
    }

    /**
     * 删除任务站点
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:taskStation:remove')")
    @Log(title = "任务站点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskStationService.deleteTaskStationByIds(ids));
    }
}
